public class SimplifiedFractions {
    public static void main(String[] args) {
        System.out.println(simplifiedFractions(1));
        System.out.println(simplifiedFractions(2));
        System.out.println(simplifiedFractions(3));
        System.out.println(simplifiedFractions(4));
    }

    public static List<String> simplifiedFractions1(int n) {
        List<String> ans = new ArrayList<>();
        if (n == 1) {
            return ans;
        }

        for (int i = 2; i <= n; i++) {//分母
            for (int j = 1; j <= i - 1; j++) {//分子
                String tmp = "";
                // 判断是否是最简分数
                boolean flag = true;
                for (int k = 2; k <= j; k++) {
                    if (i % k == 0 && j % k == 0) {
                        flag = false;
                        break;
                    }
                }
                if (!flag) {
                    continue;
                }
                tmp += String.valueOf(j) + "/" + String.valueOf(i);
                ans.add(tmp);
            }
        }
        return ans;
    }

    public static List<String> simplifiedFractions(int n) {
        List<String> ans = new ArrayList<>();
        for (int i = 2; i <= n; i++) {//分母
            for (int j = 1; j <= i - 1; j++) {//分子
                if (gcd(i, j) == 1) {
                    ans.add(j + "/" + i);
                }
            }
        }
        return ans;
    }
    public static int gcd(int a, int b) {
        return b != 0 ? gcd(b, a % b) : a;
    }
}